/**
@file tile.h
@brief Tile class definition

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 3 of the License.

@author VestniK (Sergey N.Vidyuk) sir.vestnik@gmail.com
@date 4 Oct 2008
 */
#ifndef _Tile_H_
#define _Tile_H_

#include "mjntypes.h"

namespace mjn {

   /** @brief This class discribes mahjong tile.
    *
    * Once created a tile can't change it's type. All methods exept
    * constructor are const.
    *
    * There is no validation check of tile during creation so incorrect
    * tile can be created. There is a method to check is this tile
    * valid or not: isValid()
    */
   class Tile {
      public:
         /// Tile suits enumeration
         enum TileSuits {
            NullSuit =0,
            Dot,
            Bamboo,
            Character,
            Wind,
            Dragon,
            Flower,
            Season
         };
         /// Tile ranks enumeration
         enum TileRanks {
            // Virtual null rank
            NullRank=0,
            // Suited ranks are just regular numbers
            One   =1,
            Two   =2,
            Three =3,
            Four  =4,
            Five  =5,
            Six   =6,
            Seven =7,
            Eight =8,
            Nine  =9,
            // Wind ranks
            East = mjn::East,
            South = mjn::South,
            West = mjn::West,
            North = mjn::North,
            // Dragon ranks
            Red,
            Green,
            White,
            // Flowers ranks
            Plum,
            Orchid,
            Chrisantemium,
            BambooFlower,
            // Season ranks
            Spring,
            Summer,
            Autumn,
            Winter
         };

         /// Constructor
         Tile(TileSuits suit = NullSuit, TileRanks rank = NullRank);
         /// Copy constructor
         Tile(const Tile& src) {suit = src.suit; rank = src.rank;};
         /// Copy operator
         Tile& operator= (const Tile& src);

         /// Checks for tile validity
         bool isValid() const;
         /// Compare tiles
         bool operator== (const Tile& ptrn) const;

         /// Returns tile suit
         TileSuits getSuit() const {return suit;};
         /// Returns tile rank
         TileRanks getRank() const {return rank;};
      private:
         TileSuits suit;
         TileRanks rank;
   };

} // namespace mjn

#endif
